package com.sketch.controller;

import com.sketch.commom.PageResult;
import com.sketch.commom.Result;
import com.sketch.entity.dto.DeleteDTO;
import com.sketch.entity.dto.SketchInfoDTO;
import com.sketch.entity.dto.TagDTO;
import com.sketch.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@Api(tags = "标签管理 API")
@RequestMapping(value = "/api/tag")
public class TagController {
    @Resource
    private TagService tagService;
    /**
     * 新增
     */
    @PostMapping("/add")
    @ApiOperation("新增")
    public Result add(@RequestBody @Valid TagDTO tagDTO) {
        return tagService.add(tagDTO);
    }

    /**
     * 短剧列表
     */
    @GetMapping("/list")
    @ApiOperation("短剧列表")
    public Result<PageResult<TagDTO>> list(@RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
                                                  @RequestParam(value = "size", defaultValue = "20", required = false) Integer size) {
        return tagService.list(page, size);
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(@RequestBody DeleteDTO deleteDTO) {
        return tagService.delete(deleteDTO.getId());
    }
}
